import React, { Component } from 'react'

export default class Child extends Component {
  constructor(){
    super()
    this.state={
        num:0
    }
  }
  static getDerivedStateFromProps(props,state){
    console.log('props',props);
    console.log('state',state);
    return {
        num:props.pcount
    }
  }
  render() {
    return (
      <div>
        <h2>{this.state.num}</h2>
        <button onClick={()=>this.setState({num:this.state.num+1})}>+</button>
      </div>
    )
  }
}
